package com.shawn.function;

import java.util.function.Consumer;
import java.util.function.Supplier;

/**
 * SupplierConsumerDemo
 * @author shawn
 */
public class SupplierConsumerDemo {

	public static void main(String[] args) {
		Supplier<String> supplier = new Supplier<String>() {
			@Override
			public String get() {
				return "hello,java";
			}
		};
		Consumer<String> consumer = new Consumer<String>() {
			@Override
			public void accept(String s) {
				System.out.println("匿名内部类方式： " + s);
			}
		};
		consumer.accept(supplier.get());


		Supplier<String> supplier2 = () -> {
				return "hello,java";
		};
		Consumer<String> consumer2 = s ->  {
			System.out.println("lambda expression方式： " + s);
		};
		consumer2.accept(supplier2.get());

	}

}
